home *** CD-ROM | disk | FTP | other *** search
- /* TrackLock.c */
- /*
- * Copyright © 1989 Martin Minow. All rights reserved.
- *
- * _Track_lock(track_handle, &state)
- * TrackHandle track_handle;
- *
- * _Track_unlock(&state)
- *
- * _Track_lock() is called at the beginning of all
- * functions to lock the TrackHandle in memory, save
- * the old port, clip region and text parameters; and
- * and set our port, clipRect, and text parameters.
- *
- * _Track_unlock() is called at the end to restore
- * the original parameters.
- */
-
- #include "TrackEdit.h"
- #define TR (*tr)
-
- /*
- * _Track_lock is called at the start of all
- * user-callable functions to lock the TrackRecord
- * in memory. It returns a pointer to the record.
- */
- TrackPtr
- _Track_lock(track_handle, sp)
- TrackHandle track_handle;
- register _Track_state *sp;
- {
- register TrackPtr tr;
-
- sp->track_handle = track_handle;
- sp->oldHState = HGetState(track_handle);
- MoveHHi(track_handle);
- HLock(track_handle);
- tr = (*track_handle);
- GetPort(&sp->oldPort);
- SetPort(TR.inPort);
- /*
- * Save the old clip region and set the clip region to
- * the intersection of the old region and the viewRect.
- */
- sp->oldClip = NewRgn();
- GetClip(sp->oldClip);
- ClipRect(&TR.viewRect);
- SectRgn(
- sp->oldClip, thePort->clipRgn, thePort->clipRgn);
- /*
- * Save the old drawing parameters.
- * (Perhaps even color?)
- */
- sp->oldFont = thePort->txFont; TextFont(TR.txFont);
- sp->oldFace = thePort->txFace; TextFace(TR.txFace);
- sp->oldMode = thePort->txMode; TextMode(TR.txMode);
- sp->oldSize = thePort->txSize; TextSize(TR.txSize);
- return (tr);
- }
-
- /*
- * _Track_unlock()
- * Restore the track handle to the state it had on
- * entrance.
- */
- void
- _Track_unlock(sp)
- register _Track_state *sp;
- {
- TextSize(sp->oldSize);
- TextMode(sp->oldMode);
- TextFace(sp->oldFace);
- TextFont(sp->oldFont);
- SetClip(sp->oldClip);
- DisposeRgn(sp->oldClip);
- SetPort(sp->oldPort);
- HSetState(sp->track_handle, sp->oldHState);
- }
-
-